package com.qiangshi.common.utils;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.qiangshi.common.core.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;

import java.util.*;

/**
 * RealTimeInformation对象 qs_real_time_information
 *
 * @author ccm
 * @date 2022-03-02
 */
@Data
public class QsBaseTo {
    private static final long serialVersionUID = 1L;

    /**
     * 开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;
    /**
     * 结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;
    /**
     * 页数
     */
    private Integer pageNum;
    /**
     * 页面大小
     */
    private Integer sizeNum;

    public Integer getPageNum() {
        if(Objects.isNull(pageNum)){
            return 1;
        }
        return pageNum;
    }

    public Integer getSizeNum() {
        if (Objects.isNull(sizeNum)){
            return 10;
        }
        return sizeNum;
    }

    public Date getStartTime() {
        if (Objects.isNull(startTime)) {
            return DateUtils.getLastMonthBegin();
        }
        return startTime;
    }
    public Date getStartTime2() {
        return startTime;
    }

    public Date getEndTime() {
        if (Objects.isNull(endTime)) {
            return new Date();
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(endTime);
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        calendar.set(Calendar.MINUTE, 59);
        calendar.set(Calendar.SECOND, 59);
        return calendar.getTime();
    }

}
